<?php
/**
*
* @author Blackpawn blackpawn666@hotmail.com - http://blackpawnsarchives.net
* @co_author GameCharmer admin@gamecharmer.com - http://gaming.gamecharmer.com
* @package Age of Dragons Mod :: ( Game Console Required )
* @version $Id: mysig.php 1.1.1 12-26-2009 Blackpawn
* @copyright (c) 2009 Blackpawns Archives
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/

header('Content-Type: image/png');
// image file - MUST BE PNG

define('GC_MOD', true);
define('IN_PHPBB', true);
define('AOD', true);

$phpbb_root_path =  '../../../../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
	
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/mods/game_console/gc_common.' . $phpEx);
include($phpbb_root_path . 'games/aod/common.' . $phpEx);

	
	
function ImageResize($pImage, $t_width, $t_height) {
	// Target image
	$iCanvas = @ImageCreateTrueColor($t_width, $t_height);
	
	// Source dimensions
	$s_width = ImageSX($pImage);
	$s_height = ImageSY($pImage);
	
	// Copy image
	ImageCopyResampled($iCanvas, $pImage, 0, 0, 0, 0, $t_width, $t_height, $s_width, $s_height);
	
	// Return image
 	return $iCanvas;
}

$uid = (isset($_GET['u'])) ? intval($_GET['u']) : 0;
$sid = (isset($_GET['s'])) ? intval($_GET['s']) : 0;
$fid = (isset($_GET['f'])) ? intval($_GET['f']) : 0;

switch($sid)
{
	default:
		$imagefile = 'blank.png';
		$game_img ='../img.png';
		
		
		$game_img = imagecreatefrompng($game_img);
		$game_img = ImageResize($game_img, 150, 150);
		
		$image = imagecreatefrompng($imagefile);
		$Color_Orange = imagecolorallocate($image, 255, 153, 0);
		$Color_White = imagecolorallocate($image, 255, 255, 255);
		$Color_Black = imagecolorallocate($image, 0, 0, 0);
		$Color_Blue = imagecolorallocate($image, 0, 0, 255);
		$Color_Red = imagecolorallocate($image, 255, 0, 0);

		imageCopyMerge($image, $game_img, 0, 0, 0, 0, 150, 150, 100);

		$xoff = 155;
		$yoff = 35;
	break;
	
	case 1:
		$imagefile = 'mysig.png';
		
		$image = imagecreatefrompng($imagefile);
		$Color_Orange = imagecolorallocate($image, 255, 153, 0);
		$Color_White = imagecolorallocate($image, 255, 255, 255);
		$Color_Black = imagecolorallocate($image, 0, 0, 0);
		$Color_Blue = imagecolorallocate($image, 0, 0, 255);
		$Color_Red = imagecolorallocate($image, 255, 0, 0);
		
		$xoff = 105;
		$yoff = 35;
	break;

	case 2:
		$imagefile = 'blank.png';
		$game_img = 'fantasy_1.png';
		
		
		$game_img = imagecreatefrompng($game_img);
		$game_img = ImageResize($game_img, 150, 150);
		
		$image = imagecreatefrompng($imagefile);
		$Color_Orange = imagecolorallocate($image, 255, 153, 0);
		$Color_White = imagecolorallocate($image, 255, 255, 255);
		$Color_Black = imagecolorallocate($image, 0, 0, 0);
		$Color_Blue = imagecolorallocate($image, 0, 0, 255);
		$Color_Red = imagecolorallocate($image, 255, 0, 0);

		imageCopyMerge($image, $game_img, 0, 0, 0, 0, 150, 150, 100);
		
		$xoff = 155;
		$yoff = 35;
	break;

	case 3:
		$imagefile = 'blank.png';
		$game_img = 'fantasy_2.png';
		
		
		$game_img = imagecreatefrompng($game_img);
		$game_img = ImageResize($game_img, 150, 150);
		
		$image = imagecreatefrompng($imagefile);
		$Color_Orange = imagecolorallocate($image, 255, 153, 0);
		$Color_White = imagecolorallocate($image, 255, 255, 255);
		$Color_Black = imagecolorallocate($image, 0, 0, 0);
		$Color_Blue = imagecolorallocate($image, 0, 0, 255);
		$Color_Red = imagecolorallocate($image, 255, 0, 0);

		imageCopyMerge($image, $game_img, 0, 0, 0, 0, 150, 150, 100);
		
		$xoff = 155;
		$yoff = 35;
	break;	

	case 4:
		$imagefile = 'blank.png';
		$game_img = 'fantasy_3.png';
		
		
		$game_img = imagecreatefrompng($game_img);
		$game_img = ImageResize($game_img, 150, 150);
		
		$image = imagecreatefrompng($imagefile);
		$Color_Orange = imagecolorallocate($image, 255, 153, 0);
		$Color_White = imagecolorallocate($image, 255, 255, 255);
		$Color_Black = imagecolorallocate($image, 0, 0, 0);
		$Color_Blue = imagecolorallocate($image, 0, 0, 255);
		$Color_Red = imagecolorallocate($image, 255, 0, 0);

		imageCopyMerge($image, $game_img, 0, 0, 0, 0, 150, 150, 100);
		
		$xoff = 155;
		$yoff = 35;
	break;

	case 5:
		$imagefile = 'blank.png';
		$game_img = 'fantasy_4.png';
		
		
		$game_img = imagecreatefrompng($game_img);
		$game_img = ImageResize($game_img, 150, 150);
		
		$image = imagecreatefrompng($imagefile);
		$Color_Orange = imagecolorallocate($image, 255, 153, 0);
		$Color_White = imagecolorallocate($image, 255, 255, 255);
		$Color_Black = imagecolorallocate($image, 0, 0, 0);
		$Color_Blue = imagecolorallocate($image, 0, 0, 255);
		$Color_Red = imagecolorallocate($image, 255, 0, 0);

		imageCopyMerge($image, $game_img, 0, 0, 0, 0, 150, 150, 100);
		
		$xoff = 155;
		$yoff = 35;
	break;				
}

switch($fid)
{
	default:
		$Font = "SBCStoneInscription.ttf";
		$Size = 14;
	break;
	case 1:
		$Font = "Faith_Collapsing.ttf";
		$Size = 20;
	break;
	case 2:
		$Font = "Crusades.ttf";	
		$Size = 20;
	break;
	case 3:
		$Font = "ArgBiwSc/ArgBiwSc.ttf";	
		$Size = 20;
	break;
	case 4:
		$Font = "diagoth.ttf";	
		$Size = 18;
	break;
	case 5:
		$Font = "BlackCastleMF.ttf";	
		$Size = 20;
	break;	
}

if ($uid > 1)
{
	// Fetch kingdom data
	$king = fetch_kingdom_data($uid);
	$gameid = gc_fetch_gid('aod');
	$game = gc_fetch_game_data($gameid);

	$exp 					= number_format($king['kingdom_exp']);
	$level					= number_format($king['kingdom_level']);
	$net					= number_format($king['kingdom_net']);
	$land					= number_format(fetch_total_land($uid));
	$off					= number_format($king['kingdom_off']);
	$def					= number_format($king['kingdom_def']);	
	$food					= number_format($king['kingdom_food']);
	$wood					= number_format($king['kingdom_wood']);
	$iron					= number_format($king['kingdom_iron']);
	$gold					= number_format($king['kingdom_gold']);
	$pop					= number_format($king['kingdom_pop']);
	$stamina				= number_format($king['kingdom_stamina']);
	$turns					= number_format($king['kingdom_turns']);
	$stamina_max			= number_format($king['kingdom_stamina_max']);
	$turns_max				= number_format($king['kingdom_turns_max']);
	$wins					= number_format($king['kingdom_wins']);
	$losses					= number_format($king['kingdom_losses']);
	$kingdomname			= $king['kingdom_name'];
	$ticks					= number_format($game['ticks_left']);
	$game_website 			= 'http://blackpawnsarchives.net';
	
//Header
	imagettftext($image, $Size, 0, $xoff, 30, $Color_Orange, $Font, "The Kingdom of : " . $kingdomname); 
//Line 1	
	imagestring($image, 2, $xoff + 200, $yoff + 000, "Networth : " . $net , $Color_Red);
	imagestring($image, 2, $xoff + 000, $yoff + 000, "Exp : " . $exp , $Color_Red);
	imagestring($image, 2, $xoff + 400, $yoff + 000, "Level : " . $level , $Color_Red);

//Line2
	imagestring($image, 2, $xoff + 000, $yoff + 020, "Offense : " . $off , $Color_Red);
	imagestring($image, 2, $xoff + 200, $yoff + 020, "Defense : " . $def , $Color_Red);
	imagestring($image, 2, $xoff + 400, $yoff + 020, "Land : " . $land , $Color_Red);
	
//Lines 3
	imagestring($image, 2, $xoff + 000, $yoff + 040, "Stamina : " . $stamina . " / " . $stamina_max , $Color_Red);
	imagestring($image, 2, $xoff + 200, $yoff + 040, "Turns : " . $turns . " / " . $turns_max , $Color_Red);
	imagestring($image, 2, $xoff + 400, $yoff + 040, "Wins : " . $wins , $Color_Red);
	
//Lines 4
	imagestring($image, 2, $xoff + 000, $yoff + 060, "Ticks Left : " . $ticks, $Color_Red);
	imagestring($image, 2, $xoff + 200, $yoff + 060, "Population : " . $pop, $Color_Red);
	imagestring($image, 2, $xoff + 400, $yoff + 060, "Losses : " . $losses, $Color_Red);

//Footer
	imagestring($image, 8, $xoff + 130, $yoff + 95, $game_website, $Color_Red);

}
	imagepng($image);
	
?>